package com.deere.inventory.action;

import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.deere.action.BaseAction;
import com.deere.inventory.service.InventoryService;
import com.deere.manufacture.service.ProductionService;
import com.deere.manufacture.service.WorkOrderService;
import com.deere.model.GenericPart;
import com.deere.model.ProductionOrderItem;
import com.deere.model.WorkOrder;
import com.deere.model.dto.PartDto;
import com.deere.service.BOMService;
/**
 * 库存管理
 * @author zhaohongxing
 *
 */
public class InventoryAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1412239671317258663L;

	@Autowired
	private InventoryService invService;
	 
	@Autowired 
	private BOMService bomService; 
	
	@Autowired
	private WorkOrderService woService;

	private String partCode;
	
	private String partType;
	
	private GenericPart part;
	/*
	 * 已经完成的了工单集合，将要入库
	 * 即COMPLETED
	 */
	private List<WorkOrder> workOrders;

	private  List<PartDto> partList = Collections.EMPTY_LIST;

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		// return super.execute();
		//partCode = new String(partCode.getBytes("ISO-8859-1"),"UTF-8"); 
		//this.setPartList(bomService.searchMachine(partCode,partType,25)); 
		workOrders = woService.listCompletedPOItems(part);

		return SUCCESS;
	}
	
	/******************************************/
	
	public String searchParts() throws Exception{
		this.setPartList(invService.serachInventory(partCode));
		return SUCCESS;
	}
	
	public String getPartCode() {
		return partCode;
	}

	public void setPartCode(String partCode) {
		this.partCode = partCode;
	}

	public String getPartType() {
		return partType;
	}

	public void setPartType(String partType) {
		this.partType = partType;
	}

	public List<PartDto> getPartList() {
		return partList;
	}

	public void setPartList(List<PartDto> partList) {
		this.partList = partList;
	}

	public GenericPart getPart() {
		return part;
	}

	public void setPart(GenericPart part) {
		this.part = part;
	}

	public List<WorkOrder> getWorkOrders() {
		return workOrders;
	}

	public void setWorkOrders(List<WorkOrder> workOrders) {
		this.workOrders = workOrders;
	}

}
